package com.altorithm;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

import static com.altorithm.Common.*;

/**
 * @Classname Test
 * @Date 2019/9/25 11:17
 * @auther by hqy
 */
public class Test {

    public static void main(String[] args) {
        int[] array = new int[100000];
        init(array);
//        Common.print(array);

        System.out.println("冒泡排序开始");
        int[] bubleArray = new int[array.length];
        Common.copyArray(array, bubleArray);
        Long begin = System.currentTimeMillis();
        BubbleSort.sort(bubleArray);
        Long bubleEnd = System.currentTimeMillis();
        System.out.println("冒泡耗时:" + (bubleEnd - begin));
//        Common.print(bubleArray);


        System.out.println("快速排序开始");
        int[] quick = new int[array.length];
        Common.copyArray(array, quick);
        Long quickBegin = System.currentTimeMillis();
        QuickSort.sort(quick, 0, quick.length - 1);
        Long quickEnd = System.currentTimeMillis();
        System.out.println("快速耗时:" + (quickEnd - quickBegin));

        int[] utilTest = new int[array.length];
        Common.copyArray(array, utilTest);
        Long utilBegin = System.currentTimeMillis();
        Arrays.sort(utilTest);
        Long utilEnd = System.currentTimeMillis();
        System.out.println("工具类快速耗时:" + (utilEnd - utilBegin));
//        Common.print(quick);
/*
        System.out.println("选择排序开始");
        int[] sortArray = new int[array.length];
        Common.copyArray(array, sortArray);

        Long sortBegin = System.currentTimeMillis();
        SelectedSort.sort(array);
        Long sortEnd = System.currentTimeMillis();
        System.out.println("选择排序耗时:" + (sortEnd - sortBegin));

//        Common.print(array);

        System.out.println("插入排序开始");
        int[] insertArray = new int[array.length];
        Common.copyArray(array, insertArray);

        Long selectedBegin = System.currentTimeMillis();
        InsertSort.sort(insertArray);
        Long selectedEnd = System.currentTimeMillis();
        System.out.println("插入排序耗时:" + (selectedEnd - selectedBegin));

        Common.print(insertArray);

        System.out.println("希尔排序开始");
        int[] shellArray = new int[array.length];
        Common.copyArray(array, shellArray);

        Long shellBegin = System.currentTimeMillis();
        ShellSort.sort(shellArray);
        Long shellEnd = System.currentTimeMillis();

        System.out.println("希尔排序耗时:" + (shellEnd - shellBegin));
        Common.print(shellArray);*/
    }


}
